package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo {
    public static void main(String[] args) {
        Collection C = new ArrayList();
        C.add(new Point(1,2));
        C.add(new Point(3,4));
        C.add(new Point(5,6));
        C.add(new Point(7,8));
        C.add(new Point(9,0));
        C.add(new Point(2,2));
        C.add(new Point(1,2));

        System.out.println(C);

        //contains()方法判断依据是equals()比较为true的情况；
        Point p=new Point(1,2);
        boolean cc=C.contains(p);
       if(cc){
           C.remove(p);
           System.out.println("删除成功");
           System.out.println(C);
       }else{
           System.out.println("删除失败");
       }



       Collection dd=new ArrayList();
       Point pp=new Point(1,2);
       dd.add(pp);
        System.out.println("pp:"+pp);
        System.out.println("dd:"+dd);


        pp.setX(100);
        System.out.println("pp:"+pp);
        System.out.println("dd:"+dd);

















       /* //默认调重写String()方法，以数组形式返回
        Collection c=new ArrayList();
        c.add(1);
        c.add(2);
        c.add(3);
        c.add(4);
        c.add(5);
        System.out.println(c);
        System.out.println(c.size());
        System.out.println(c.isEmpty());
        c.clear();
        System.out.println(c.isEmpty());
        System.out.println("size:"+c.size());


        */


    }
}
